home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MISC / SHELL.ARC / Shell / Sources / c / Misc < prev    next >
Text File  |  1994-07-14  |  4KB  |  178 lines

  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. #include "DeskLib:GFX.h"
  7. #include "DeskLib:Coord.h"
  8. #include "DeskLib:WimpSWIs.h"
  9. #include "DeskLib:Error.h"
  10.  
  11. #include "Shell.Extra.h"
  12.  
  13.  
  14.  
  15. #define _PLOT_MAX 16384
  16.  
  17.  
  18. char Shell_string[ 1 + Shell_stringMAX];
  19.  
  20.  
  21. void    Shell_ConvertToTextRect( wimp_rect *rect)
  22. {    int    y;
  23.  
  24. rect->min.x = rect->min.x / Shell_TEXTXSIZE;
  25. rect->max.x = rect->max.x / Shell_TEXTXSIZE;
  26.  
  27. y        = rect->min.y;
  28. rect->min.y    = ( 0 - rect->max.y) / Shell_TEXTYSIZE;
  29. rect->max.y    = ( 0 - y          ) / Shell_TEXTYSIZE;
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36. void Shell_ConvertToSubRect( wimp_rect *rect, const wimp_rect *bigrect)
  37. {
  38. Shell_MakeGE( rect->min.x, bigrect->min.x);
  39. Shell_MakeGE( rect->min.y, bigrect->min.y);
  40. Shell_MakeLE( rect->max.x, bigrect->max.x);
  41. Shell_MakeLE( rect->max.y, bigrect->max.y);
  42.  
  43. rect->min.x -= bigrect->min.x;
  44. rect->max.x -= bigrect->min.x + 1;
  45. rect->min.y -= bigrect->min.y;
  46. rect->max.y -= bigrect->min.y + 1;
  47.  
  48. return;
  49. }
  50.  
  51.  
  52.  
  53. void Shell_ConvertToSubRect2( wimp_rect *rect, wimp_point bigsize)
  54. {
  55. Shell_MakeGE( rect->min.x, 0);
  56. Shell_MakeGE( rect->min.y, 0);
  57. Shell_MakeLE( rect->max.x, bigsize.x);
  58. Shell_MakeLE( rect->max.y, bigsize.y);
  59.  
  60. rect->max.x -= 1;
  61. rect->max.y -= 1;
  62.  
  63. return;
  64. }
  65.  
  66.  
  67.  
  68.  
  69. /*
  70. void    Shell_PrintString( const char *s, int x, int y, const Shell_convertpoint convert)
  71. {
  72. x = Shell_ConvertXToScreen( x, convert);
  73. y = Shell_ConvertYToScreen( y, convert);
  74. GFX_Move( x, y-Shell_PIXELYSIZE);
  75. GFX_Write0( (char *) s);
  76. }
  77. */
  78. /* This is now a macro    */
  79.  
  80.  
  81.  
  82.  
  83.  
  84. void    Shell_RectangleFill( const wimp_rect *rect, Shell_convertpoint convert)
  85. {    wimp_rect    rect2    = *rect;
  86. Shell_ConvertRectToScreen( &rect2, convert);
  87.  
  88. /*    OS_Plot expects 16 bit numbers    */
  89. Shell_MakeGE( rect2.min.x, -_PLOT_MAX);
  90. Shell_MakeGE( rect2.min.y, -_PLOT_MAX);
  91. Shell_MakeLE( rect2.max.x, _PLOT_MAX);
  92. Shell_MakeLE( rect2.max.y, _PLOT_MAX);
  93.  
  94. /* the '-Shell_PIXELYSIZE's are to exclude the top and right edges, as in Wimp_ForceRedraw etc. */
  95. GFX_RectangleFill(
  96.     rect2.min.x,
  97.     rect2.min.y,
  98.     rect2.max.x - rect2.min.x - Shell_PIXELYSIZE,
  99.     rect2.max.y - rect2.min.y - Shell_PIXELYSIZE
  100.     );
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107. void    Shell_RectangleFill2( int xmin, int ymin, int xmax, int ymax,
  108.     const Shell_convertpoint convert)
  109. {
  110. xmin = Shell_ConvertXToScreen( xmin, convert);
  111. ymin = Shell_ConvertYToScreen( ymin, convert);
  112. xmax = Shell_ConvertXToScreen( xmax, convert);
  113. ymax = Shell_ConvertYToScreen( ymax, convert);
  114.  
  115. /*    OS_Plot expects 16 bit numbers    */
  116. Shell_MakeGE( xmin, -_PLOT_MAX);
  117. Shell_MakeGE( ymin, -_PLOT_MAX);
  118. Shell_MakeLE( xmax, _PLOT_MAX);
  119. Shell_MakeLE( ymax, _PLOT_MAX);
  120.  
  121. GFX_RectangleFill( xmin, ymin, xmax-xmin-Shell_PIXELYSIZE, ymax-ymin-Shell_PIXELYSIZE);
  122. }
  123.  
  124.  
  125.  
  126.  
  127.  
  128. void    Shell_RectangleFill3( int x, int y, int width, int height,
  129.     Shell_convertpoint convert)
  130. {
  131. x = Shell_ConvertXToScreen( x, convert);
  132. y = Shell_ConvertYToScreen( y, convert);
  133.  
  134. /*    OS_Plot expects 16 bit numbers    */
  135. Shell_MakeGE( x, -_PLOT_MAX);
  136. Shell_MakeGE( y, -_PLOT_MAX);
  137. Shell_MakeLE( x, _PLOT_MAX);
  138. Shell_MakeLE( y, _PLOT_MAX);
  139.  
  140. GFX_RectangleFill( x, y, width, height);
  141. }
  142.  
  143.  
  144.  
  145.  
  146. void    Shell_ConvertToSubTextRect( wimp_rect *rect, const wimp_rect *bigrect)
  147. {
  148. Shell_MakeGE( rect->min.x, bigrect->min.x);
  149. Shell_MakeGE( rect->min.y, bigrect->min.y);
  150. Shell_MakeLE( rect->max.x, bigrect->max.x);
  151. Shell_MakeLE( rect->max.y, bigrect->max.y);
  152. rect->min.x = (rect->min.x - bigrect->min.x   ) / Shell_TEXTXSIZE;
  153. rect->max.x = (rect->max.x - bigrect->min.x -1) / Shell_TEXTXSIZE;
  154.     {    int y = rect->min.y;
  155.     rect->min.y = ( bigrect->max.y - rect->max.y ) / Shell_TEXTYSIZE;
  156.     rect->max.y = ( bigrect->max.y - y - 1       ) / Shell_TEXTYSIZE;
  157.     }
  158. return;
  159. }
  160.  
  161. void    Shell_ConvertToSubTextRect2( wimp_rect *rect, wimp_point rectsize)
  162. {
  163. Shell_MakeGE( rect->min.x, 0);
  164. Shell_MakeGE( rect->min.y, 0);
  165. Shell_MakeLE( rect->max.x, rectsize.x);
  166. Shell_MakeLE( rect->max.y, rectsize.y);
  167.  
  168. rect->min.x = rect->min.x / Shell_TEXTXSIZE;
  169. rect->max.x = (rect->max.x - 1) / Shell_TEXTXSIZE;
  170.  
  171.     {    int y = rect->min.y;
  172.     rect->min.y = ( rectsize.y - rect->max.y ) / Shell_TEXTYSIZE;
  173.     rect->max.y = ( rectsize.y - y - 1       ) / Shell_TEXTYSIZE;
  174.     }
  175. return;
  176. }
  177.  
  178.